# 作者: YYJ
# 2025年07月11日21时11分46秒
# 2486249622@qq.com
import time
from multiprocessing import Process, Queue

def write(q):
    for i in range(10):
        q.put(i)
        time.sleep(0.1)
        print(f'写入数据{i}')

def read(q):
    while True:
        if q.empty():
            break
        else:
            print(q.get())
            time.sleep(0.2)

if __name__ == '__main__':
    q = Queue() # 消息队列
    p1 = Process(target=write, args=(q,))
    p1.start()
    p2 = Process(target=read, args=(q,))
    p2.start()
    p1.join()
    p2.join()
